package com.ubaer.zsycz.ui.activity;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lsw.util.StringUtil;
import com.ubaer.zsycz.R;
import com.ubaer.zsycz.model.OrderDetailsModel;
import com.ubaer.zsycz.ui.base.activity.TitleBarActivity;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/9/25 0025.
 */

public class OrderDetailsActivity extends TitleBarActivity<OrderDetailsPresenter> implements OrderDetailsContract.View {

    String id;
    //充值状态
    @BindView(R.id.tv_status)
    TextView tv_status;
    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_car_number)
    TextView tv_car_number;
    @BindView(R.id.tv_price)
    TextView tv_price;
    @BindView(R.id.tv_order_no)
    TextView tv_order_no;
    @BindView(R.id.tv_time)
    TextView tv_time;
    @BindView(R.id.ll_fail)
    LinearLayout ll_fail;
    @BindView(R.id.tv_reason)
    TextView tv_reason;

    @Override
    protected void initInjector() {
        mActivityComponent.inject(this);
    }

    @Override
    protected void initEventAndData() {
        id = getIntent().getStringExtra("id");
        if (!StringUtil.isNullOrEmpty(id))
            mPresenter.getData(id);
    }

    @Override
    protected int setContentLayoutView() {
        return R.layout.activity_order_details;
    }

    @Override
    protected void setActionBarDetail() {

    }

    @Override
    public void setData(OrderDetailsModel model) {
        if (model != null) {
            if (model.getStatus() == 1) {
                tv_status.setText("充值成功");
                tv_status.setTextColor(mContext.getResources().getColor(R.color.color_53913E));
                ll_fail.setVisibility(View.GONE);
            } else if (model.getStatus() == 2) {
                tv_status.setText("充值失败");
                tv_status.setTextColor(mContext.getResources().getColor(R.color.color_C73922));
                ll_fail.setVisibility(View.VISIBLE);
                tv_reason.setText(model.getReason());
            } else if (model.getStatus() == 0) {
                tv_status.setText("待处理");
                tv_status.setTextColor(mContext.getResources().getColor(R.color.color_53913E));
                ll_fail.setVisibility(View.GONE);
            }
            tv_name.setText(model.getOrder_name());
            tv_car_number.setText(model.getCard_num());
            tv_price.setText(model.getMoney());
            tv_order_no.setText(model.getOrder_no());
            tv_time.setText(model.getCreated_at());
        }
    }


    @Override
    public void openLogin() {
        OpenLogin();
    }
}
